#ifndef		__DTS1580_HW_H
#define		__DTS1580_HW_H

#include    	"dts1580_map.h"

typedef		short 			int16_t;
typedef		int 			int32_t;
typedef		long long 		int64_t;
typedef		unsigned char 		uint8_t;
typedef 	unsigned short 		uint16_t;
typedef 	unsigned int 		uint32_t;
typedef 	unsigned long long 	uint64_t;

//- DMAS
#define     	DMAS_CHx_SAR(a)     	((volatile unsigned *)(DMAS_BASE + 0x40 + (a * 0x20)))
#define     	DMAS_CHx_DAR(a)     	((volatile unsigned *)(DMAS_BASE + 0x44 + (a * 0x20)))
#define     	DMAS_CHx_CTL0(a)    	((volatile unsigned *)(DMAS_BASE + 0x48 + (a * 0x20)))
#define     	DMAS_CHx_CTL1(a)    	((volatile unsigned *)(DMAS_BASE + 0x4C + (a * 0x20)))
#define     	DMAS_CHx_CA(a)      	((volatile unsigned *)(DMAS_BASE + 0x50 + (a * 0x20)))

//- TIMER
#define     	CPR_TIMER_CLK_CTL(a)	((volatile unsigned *)(CPR_BASE + 0x58 + (a * 0x04)))
#define     	TIMERx_TLC(a)     		((volatile unsigned *)(TIMER_BASE + 0x00 + (a * 0x14)))
#define     	TIMERx_TCV(a)     		((volatile unsigned *)(TIMER_BASE + 0x04 + (a * 0x14)))
#define     	TIMERx_TCR(a)     		((volatile unsigned *)(TIMER_BASE + 0x08 + (a * 0x14)))
#define     	TIMERx_TIC(a)     		((volatile unsigned *)(TIMER_BASE + 0x0C + (a * 0x14)))
#define     	TIMERx_TIS(a)      		((volatile unsigned *)(TIMER_BASE + 0x10 + (a * 0x14)))
	
//- UART
#define				CPR_UARTx_CLK_GRCTL(a)	        ((volatile unsigned *)(CPR_BASE + 0x30 + (a * 0x08)))
#define				CPR_UARTx_CLK_CTL(a)		    ((volatile unsigned *)(CPR_BASE + 0x34 + (a * 0x08)))
#define				UARTx_RBR(a)					((volatile unsigned *)(UART0_BASE + 0x00 + (a * 0x1000)))
#define				UARTx_THR(a)					((volatile unsigned *)(UART0_BASE + 0x00 + (a * 0x1000)))
#define				UARTx_DLL(a)					((volatile unsigned *)(UART0_BASE + 0x00 + (a * 0x1000)))
#define				UARTx_IER(a)					((volatile unsigned *)(UART0_BASE + 0x04 + (a * 0x1000)))
#define				UARTx_DLH(a)					((volatile unsigned *)(UART0_BASE + 0x04 + (a * 0x1000)))
#define				UARTx_IIR(a)					((volatile unsigned *)(UART0_BASE + 0x08 + (a * 0x1000)))
#define				UARTx_FCR(a)					((volatile unsigned *)(UART0_BASE + 0x08 + (a * 0x1000)))
#define				UARTx_TCR(a)					((volatile unsigned *)(UART0_BASE + 0x0c + (a * 0x1000)))
#define				UARTx_MCR(a)					((volatile unsigned *)(UART0_BASE + 0x10 + (a * 0x1000)))
#define				UARTx_TSR(a)					((volatile unsigned *)(UART0_BASE + 0x14 + (a * 0x1000)))
#define				UARTx_MSR(a)					((volatile unsigned *)(UART0_BASE + 0x18 + (a * 0x1000)))
#define				UARTx_USR(a)					((volatile unsigned *)(UART0_BASE + 0x7c + (a * 0x1000)))

//- SPI
#define             CPR_SPIx_MCLK_CTL(a)            ((volatile unsigned *)(CPR_BASE + 0x050 + (a*0x04)))
#define		        SSIx_CTRL0(a)					((volatile unsigned *)(SPI0_BASE + 0x00 + (a * 0x1000)))
#define		        SSIx_EN(a)						((volatile unsigned *)(SPI0_BASE + 0x08 + (a * 0x1000)))
#define		        SSIx_SE(a)						((volatile unsigned *)(SPI0_BASE + 0x10 + (a * 0x1000)))
#define		        SSIx_BAUD(a)					((volatile unsigned *)(SPI0_BASE + 0x14 + (a * 0x1000)))
#define		        SSIx_TXFTL(a)					((volatile unsigned *)(SPI0_BASE + 0x18 + (a * 0x1000)))
#define		        SSIx_RXFTL(a)					((volatile unsigned *)(SPI0_BASE + 0x1c + (a * 0x1000)))
#define		        SSIx_TXFL(a)					((volatile unsigned *)(SPI0_BASE + 0x20 + (a * 0x1000)))
#define		        SSIx_RXFL(a)					((volatile unsigned *)(SPI0_BASE + 0x24 + (a * 0x1000)))
#define		        SSIx_STS(a)						((volatile unsigned *)(SPI0_BASE + 0x28 + (a * 0x1000)))
#define		        SSIx_IE(a)						((volatile unsigned *)(SPI0_BASE + 0x2c + (a * 0x1000)))
#define		        SSIx_IS(a)						((volatile unsigned *)(SPI0_BASE + 0x30 + (a * 0x1000)))
#define		        SSIx_RIS(a)						((volatile unsigned *)(SPI0_BASE + 0x34 + (a * 0x1000)))
#define		        SSIx_TXOIC(a)					((volatile unsigned *)(SPI0_BASE + 0x38 + (a * 0x1000)))
#define		        SSIx_RXOIC(a)					((volatile unsigned *)(SPI0_BASE + 0x3c + (a * 0x1000)))
#define		        SSIx_RXUIC(a)					((volatile unsigned *)(SPI0_BASE + 0x40 + (a * 0x1000)))
#define		        SSIx_IC(a)						((volatile unsigned *)(SPI0_BASE + 0x48 + (a * 0x1000)))
#define		        SSIx_DMAS(a)					((volatile unsigned *)(SPI0_BASE + 0x4c + (a * 0x1000)))
#define		        SSIx_DMATDL(a)					((volatile unsigned *)(SPI0_BASE + 0x50 + (a * 0x1000)))
#define		        SSIx_DMARDL(a)					((volatile unsigned *)(SPI0_BASE + 0x54 + (a * 0x1000)))
#define		        SSIx_DATA(a)					((volatile unsigned *)(SPI0_BASE + 0x60 + (a * 0x1000)))

//- RTC
#define		        RTC_CMR_X(a)					((volatile unsigned *)(RTC_BASE + 0x08 + (a * 0x4)))

//- PWM
#define     	    PWMx_EN(a)                  	((volatile unsigned *)(PWM_BASE + 0x0000 + (a*0x40)))
#define     	    PWMx_UP(a)                     	((volatile unsigned *)(PWM_BASE + 0x0004 + (a*0x40)))
#define     	    PWMx_RST(a)                    	((volatile unsigned *)(PWM_BASE + 0x0008 + (a*0x40)))
#define     	    PWMx_P(a)                      	((volatile unsigned *)(PWM_BASE + 0x000c + (a*0x40)))
#define     	    PWMx_OCPY(a)                   	((volatile unsigned *)(PWM_BASE + 0x0010 + (a*0x40)))




#define     	__write_hw_reg32(reg,val)  ((*reg) = (val))
#define     	__read_hw_reg32(reg, val)  ((val) = (*reg))  


#endif
